Skip to content

stdlib: Add missing Psych methods and exception classes#2850

Open
marcoroth wants to merge 2 commits intoruby:masterfrom
marcoroth:psych-load-unsafe-file
Open

stdlib: Add missing Psych methods and exception classes#2850
marcoroth wants to merge 2 commits intoruby:masterfrom
marcoroth:psych-load-unsafe-file

Conversation

@marcoroth
Copy link

This pull request adds missing type declarations for Psych:

Methods

  • Psych.safe_load_file - Safely loads YAML from a file
  • Psych.unsafe_load_file - Loads YAML from a file (unsafe)

Exception Classes

  • Psych::SyntaxError - Raised on YAML syntax errors
  • Psych::Exception - Base exception class
  • Psych::BadAlias - Raised for alias errors
  • Psych::DisallowedClass - Raised when loading disallowed classes

Motivation

These methods and classes are commonly used but were missing from the stdlib declarations, causing type errors in projects using YAML.safe_load_file or rescuing Psych::SyntaxError.

@marcoroth marcoroth changed the title Add missing Psych methods and exception classes stdlib: Add missing Psych methods and exception classes Feb 14, 2026
@marcoroth marcoroth force-pushed the psych-load-unsafe-file branch from 3c68128 to 6ed90f1 Compare February 14, 2026 23:25
Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Can you add test cases for the safe_load_file and unsafe_load_file in test/stdlib/psych_test.rb? The tests for safe_load method should be a good example.

@marcoroth
Copy link
Author

Thanks for the review @soutaro! 🙏🏼 I just added tests for both safe_load_file and unsafe_load_file! 🙌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments